#include "myScreen.h"

MyScreen::MyScreen()
{
}

MyScreen::~MyScreen()
{
}

void MyScreen::Render()
{
	this->pEngine->GetGraphics()->DrawCamera(this->pMyCamera);

	this->pEngine->GetGraphics()->EnableDepthTesting();

	this->pEngine->GetGraphics()->DrawEntity(this->pMyEntity);

	this->pEngine->GetGraphics()->DisableDepthTesting();

	this->pEngine->GetGraphics()->Setup2DProjection();
}

void MyScreen::Update(float fDelta)
{
	this->pMyEntity->Turn(60.0f * fDelta, 60.0f * fDelta, 0);
}

void MyScreen::Load()
{
	this->pMyCamera = new Camera(0, 0, this->ScreenWidth(), this->ScreenHeight());
	this->pMyCamera->SetPerspectiveProjection(60.0f, 1.33f, 0.1f, 300.0f);
	this->pMyCamera->SetBackgroundColor(Color(255, 189, 38));
	this->pMyCamera->Move(0, 0, 5);

	this->pMyTexture = this->pEngine->GetGraphics()->LoadTexture("media/box.bmp");

	this->pMyEntity = new StaticEntity();
	this->pMyEntity->AddModel(Model::CreateCube(1, 1, 1));

	Model *pModel = this->pMyEntity->GetModel(0);
	pModel->SetTexture(this->pMyTexture);

	Mesh *pMesh = pModel->GetMesh();
	
	pMesh->BuildMesh();
}

void MyScreen::Unload()
{
	this->pMyEntity->Destroy();

	delete this->pMyCamera;
	delete this->pMyEntity;
	delete this->pMyTexture;
}